<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <ui:composition template="../TemplateAdmin.xhtml">
        <ui:define name="title">
            <h:outputText value="OrderDetail"></h:outputText>
        </ui:define>       
        <ui:define name="body"> 
            <h:form id="form">
                <p:growl id="messages" showDetail="true"/> 
                <p:dataTable id="dataTable" var="item" value="#{managerController.getListManagerByID(loginController.managerLogin.mnID)}"
                             paginator="true" rows="10" paginatorPosition="bottom" resizableColumns="true"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="5,10,15" style="width: 100%" widgetVar="managerTable"
                             editable="true">
                    <f:facet name="header">
                        <h:outputText value="My Information "/>                    
                    </f:facet>

                    <p:ajax event="rowEdit" listener="#{managerController.onEdit}" />
                    <p:ajax event="rowEditCancel" listener="#{managerController.onEditCancel}" />

                    <p:column headerText="ID" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.mnID}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.mnID}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="Name"  >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.mnName}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.mnName}" style="width: 100%">
                                    <f:validateLength minimum="1" /> 
                                </h:inputText>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>                
                    <p:column headerText="UserName">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.mnUserName}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.mnUserName}" style="width: 100%">
                                    <f:validateLength minimum="1" maximum="10" />
                                </h:inputText>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>

                    <p:column headerText="Email" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.mnEmail}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.mnEmail}" style="width: 100%">
                                    <!-- <f:validateRegex pattern="^[a-zA-Z]" /> -->
                                </h:inputText>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="Phone" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.mnPhone}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.mnPhone}" style="width: 100%">
                                    <!-- <f:validateRegex pattern="^[a-zA-Z]" /> -->
                                </h:inputText>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="Adress" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.mnAdress}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.mnAdress}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>               

                    <p:column headerText="Status" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.mnStatus}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:selectBooleanCheckbox value="#{item.mnStatus}" />
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column> 
                    <p:column  headerText="Permission" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="Admin" rendered="#{item.mnPermission == 0}"/>  
                                <h:outputText value="Staff Order" rendered="#{item.mnPermission == 1}"/>  
                                <h:outputText value="Staff Project" rendered="#{item.mnPermission == 2}"/>  
                            </f:facet>
                            <f:facet name="input">  
                                <h:outputText value="Admin" rendered="#{item.mnPermission == 0}"/>  
                                <h:outputText value="Staff Order" rendered="#{item.mnPermission == 1}"/>  
                                <h:outputText value="Staff Project" rendered="#{item.mnPermission == 2}"/>  
                            </f:facet>
                        </p:cellEditor> 
                    </p:column>
                    <p:column>
                        <p:rowEditor/>
                    </p:column>
                </p:dataTable>
               
            </h:form>
        </ui:define>
    </ui:composition>
</html>

